package top.codedance.iotp.iot.sdk.entity;

import top.codedance.iotp.common.util.ByteUtils;

import java.math.BigInteger;

public class SlaveItem {
    private int slaveId;
    private int function;
    private int offset;
    private int datatype;
    private Object value;
    private String cmd;

    public SlaveItem() { }

    public SlaveItem(int slaveId, String cmd) {
        this.slaveId = slaveId;
        this.cmd = cmd;
    }

    public SlaveItem(int slaveId, int function, int offset, int datatype) {
        this.slaveId = slaveId;
        this.function = function;
        this.offset = offset;
        this.datatype = datatype;
    }

    public SlaveItem(int slaveId, int function, int offset, int datatype, Object value) {
        this(slaveId, function, offset, datatype);
        this.value = value;
    }

    public int getSlaveId() {
        return slaveId;
    }

    public void setSlaveId(int slaveId) {
        this.slaveId = slaveId;
    }

    public int getFunction() {
        return function;
    }

    public void setFunction(int function) {
        this.function = function;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getDatatype() {
        return datatype;
    }

    public void setDatatype(int datatype) {
        this.datatype = datatype;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public void setBeValue(byte value) {
        this.value = ByteUtils.LeToBe(value);
    }

    public void setBeValue(short value) {
        this.value = ByteUtils.LeToBe(value);
    }

    public void setBeValue(int value) {
        this.value = ByteUtils.LeToBe(value);
    }

    public void setBeValue(long value) {
        this.value = ByteUtils.LeToBe(value);
    }

    public void setBeValue(BigInteger value) {
        this.value = ByteUtils.LeToBe(value);
    }

    public void setBeValue(float value) {
        this.value = ByteUtils.LeToBe(value);
    }

    public void setBeValue(double value) {
        this.value = ByteUtils.LeToBe(value);
    }

    public String getCmd() {
        return cmd;
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }
}
